package practice_0524;

public class practice03 {
    public static void main(String[] args) {
        //演示杨辉三角
        int[][] arr = new int[10][10];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < i +1; j++) {
                if(j == 0 || j == i){
                    arr[i][j] = 1;
                }else{
                    arr[i][j] = arr[i - 1][j - 1] +arr[i - 1][j];
                }
            }
        }
        //遍历数组
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < i +1; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }
}
